package main

import (
	"fmt"
	"net"
)

func main() {
	udpConn, err := net.DialUDP("udp", &net.UDPAddr{
		IP:   net.IPv4(192, 168, 1, 5),
		Port: 20001,
	}, &net.UDPAddr{
		IP:   net.IPv4(127, 0, 0, 1),
		Port: 20000,
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	defer udpConn.Close()
	for i := 0; i < 20; i++ {
		_, err = udpConn.Write([]byte("hello golang!"))
		if err != nil {
			fmt.Println(err)
			return
		}
	}
}
